package com.sc.nft.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserIncomeRecord;
import com.sc.nft.entity.vo.IncomeDetailsVO;
import com.sc.nft.entity.vo.UserIncomeDetailsVO;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * (sc_user_income_record)数据Mapper
 *
 * @author Sun
 * @since 2022-09-20 18:32:41
 * @description 由 Mybatisplus Code Generator 创建
*/
@Mapper
public interface UserIncomeRecordMapper extends BaseMapper<UserIncomeRecord> {

    /**
     * 查询昨日收益
     * @param userId
     * @return
     */
    BigDecimal findSumAmountByUserIdAndYesterDay(@Param("userId") Long userId);

    /**
     * 根据层级查询列表
     * @param userId
     * @param incomeHierarchy
     * @return
     */
    Page<IncomeDetailsVO> findListByHierarchyAndUserId(Page page, @Param("userId") Long userId, @Param("incomeHierarchy")Integer incomeHierarchy);
    Page<IncomeDetailsVO> findListByHierarchyAndUserIdNewVesion(Page page, @Param("userId") Long userId, @Param("incomeHierarchy")List<Integer> incomeHierarchy);

    Page<UserIncomeDetailsVO> pageIncomeList(Page page, @Param("incomeType") Integer incomeType, @Param("userId") Long userId,
                                               @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    /**
     * 昨天昨日收益总额
     * @return
     */
    BigDecimal getToDayIncomeNum();

    BigDecimal getToDayIncomeNumByDay(@Param("day") String day);

    /**
     * 查询类型的昨日收益
     * @param incomeType
     * @return
     */
    BigDecimal getToDaySumIncomeByType(@Param("incomeType") Integer incomeType);

    BigDecimal getToDaySumIncomeByTypeByDay(@Param("incomeType") Integer incomeType, @Param("day") String day);

    /**
     * 查询类型的昨日收益 并且在这里订单中
     * @param incomeType
     * @param orderNoList
     * @return
     */
    BigDecimal getToDaySumIncomeByTypeAndOrderNo(@Param("incomeType")Integer incomeType,@Param("orderNoList") List<String> orderNoList);

    BigDecimal getToDaySumIncomeByTypeAndOrderNoByDay(@Param("incomeType")Integer incomeType,@Param("orderNoList") List<String> orderNoList, @Param("day") String day);
}
